package doubleball;

/**
 * 球类
 */
public class Ball {
    /**
     * 双色球的值
     */
    private int value;
    /**
     * 红球或蓝球
     */
    private String color;

    public Ball() {
    }

    public Ball(String color) {
        this.color = color;
        this.generate();
    }

    public Ball(int value, String color) {
        this.value = value;
        this.color = color;
    }

    /**
     * 随机产生一个值赋给当前对象的value属性
     */
    public void generate(){
        if("红球".equals(this.color)){
            this.value = (int)(Math.random() * 33) + 1;
        }else if("蓝球".equals(this.color)){
            this.value = (int)(Math.random() * 16) + 1;
        }
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
}
